/**
 * API配置
 */

// API基础配置
export const API_CONFIG = {
  // 基础URL，根据环境变量或构建模式设置
  BASE_URL: import.meta.env.VITE_API_BASE_URL || 'https://api.hezerxunhuan.com/api/v1',

  // 超时时间
  TIMEOUT: 30000,

  // 上传文件的URL
  UPLOAD_URL: import.meta.env.VITE_UPLOAD_URL || 'https://api.hezerxunhuan.com/api/v1/upload',

  // WebSocket URL
  WS_URL: import.meta.env.VITE_WS_URL || 'wss://api.hezerxunhuan.com/ws',

  // 云存储配置 (根据实际使用的OSS/COS配置)
  OSS: {
    // 阿里云OSS或腾讯云COS的配置
    BUCKET: '',
    REGION: '',
    // 由后端提供临时凭证
  }
}

// 接口路径
export const API_PATHS = {
  // 认证相关
  AUTH: {
    WECHAT_LOGIN: '/auth/wechat-login',
    BIND_PHONE: '/auth/bind-phone',
    REFRESH_TOKEN: '/auth/refresh-token'
  },

  // 用户相关
  USER: {
    PROFILE: '/users/profile',
    UPDATE_PROFILE: '/users/profile',
    STATS: '/users/stats',
    POSTS: '/users/posts',
    FAVORITES: '/users/favorites'
  },

  // 分类相关
  CATEGORY: {
    LIST: '/categories',
    CONFIG: '/categories/:id/config'
  },

  // 信息发布相关
  POST: {
    LIST: '/posts/feed',
    DETAIL: '/posts/:id',
    CREATE: '/posts',
    UPDATE: '/posts/:id',
    DELETE: '/posts/:id',
    SEARCH: '/posts/search',
    LIMIT: '/posts/limit',
    VIEW: '/posts/:id/view',
    LIKE: '/posts/:id/like',
    FAVORITE: '/posts/:id/favorite'
  },

  // 消息相关
  MESSAGE: {
    CONVERSATIONS: '/conversations',
    MESSAGES: '/conversations/:id/messages',
    SEND: '/conversations/:id/messages',
    CREATE_CONVERSATION: '/conversations',
    MARK_READ: '/conversations/:id/read'
  },

  // 举报相关
  REPORT: {
    CREATE: '/reports'
  },

  // 系统配置
  SYSTEM: {
    CONFIGS: '/system/configs'
  },

  // 文件上传
  UPLOAD: {
    IMAGE: '/upload/image',
    VIDEO: '/upload/video',
    VOICE: '/upload/voice',
    GET_TOKEN: '/upload/token' // 获取云存储临时凭证
  }
}

// HTTP状态码
export const HTTP_STATUS = {
  SUCCESS: 200,
  BAD_REQUEST: 400,
  UNAUTHORIZED: 401,
  FORBIDDEN: 403,
  NOT_FOUND: 404,
  TOO_MANY_REQUESTS: 429,
  SERVER_ERROR: 500
}

// 业务状态码
export const BIZ_CODE = {
  SUCCESS: 200,
  ERROR: -1,
  UNAUTHORIZED: 401,
  TOKEN_EXPIRED: 10001,
  DAILY_LIMIT_EXCEEDED: 20001,
  CONTENT_VIOLATION: 20002
}
